package com.alumni_circle.core.mapper.rbac;

import com.alumni_circle.core.entity.rbac.Authority;
import com.alumni_circle.core.entity.rbac.VO.AuthoritySearchVO;
import com.alumni_circle.core.entity.rbac.VO.AuthorityUpdateVO;
import com.alumni_circle.core.entity.rbac.VO.AuthorityViewVO;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @author  龙小虬
 * @create  2020-08-02 20:37
 **/
public interface AuthorityMapper extends BaseMapper<Authority> {

    @Select("SELECT id,`comment`,state,update_name,update_time,url,permissions\n" +
            "FROM authority \n" +
            "WHERE (id like concat('%',#{id},'%')) AND (`comment` like concat('%',#{comment},'%')) AND (state like concat('%',#{state},'%'))\n" +
            "AND (update_name  like concat('%',#{updateName},'%')) AND (update_time like concat('%',#{updateTime},'%')) AND (url like concat('%',#{url},'%'))")
    List<AuthoritySearchVO> searchAuthority(@Param("id")String id,@Param("comment")String comment,@Param("state")String state,@Param("updateName")String updateName,@Param("updateTime")String updateTime,@Param("url")String url);

    @Select("SELECT authority.id,authority.permissions,authority.url\n" +
            "FROM authority")
    List<AuthorityUpdateVO> getAllPermissionsUrl();

    @Select("SELECT id,update_time,permissions,url,state,`comment`\n" +
            "FROM authority")
    List<AuthorityViewVO> getAll();

}
